<?php
/**
 * Created by PhpStorm.
 * User: fengzi
 * Date: 2019/5/29
 * Time: 17:19
 */

namespace app\vehicle\logic;
use app\vehicle\model\Ad;
use app\common\model\Site;
use app\common\model\SiteTeam;
use app\common\model\Organization;
use app\vehicle\model\City;
use app\vehicle\model\Article;
use app\vehicle\model\PracticeLog;
class publicLogic
{
    public function getTime(){
        $time = time();
        $arr = [];
        for($i=0;$i<100;$i++){
            $now_time = $time+$i*86400;
            $date = date('Y-m-d', $now_time);
            $arr[$i]['str'] = $date;
            $arr[$i]['year'] = date('Y', $now_time);
        }
        return $arr;
    }
    public function getAd(){
        $info['wish'] = Ad::where('cate_id','eq',2)->find();
        $info['integral'] = Ad::where('cate_id','eq',3)->find();
        $info['donation'] = Ad::where('cate_id','eq',4)->find();
        return $info;
    }
    public function getSite($data){
        $limit = $data['limit']??1000;
        $where[] = ['status','eq',1];
        $where[] = ['id','>',1];
        $data['cate_id'] && $where[] = ['cate_id','eq',$data['cate_id']];
        $site = Site::where($where)->order('number desc')->limit($limit)->select();
        return $site;
    }
    public function getOrganization($data){
        $limit = $data['limit']??100;
        $site = SiteTeam::where('status','eq',1)->order('number desc')->limit($limit)->select();
        return $site;
    }
    public function getArticleInfo($id){
        $result = Article::get($id);
        return $result;
    }
    public function getAdList(){
        $list = Ad::where('status','eq',1)->where('cate_id','eq',1)->order('ordid desc')->select();
        return $list;
    }
    public function getCityList(){
        $city = City::where('status','eq',1)->order('ordid desc')->column('name');
        return [$city];
    }
}